# 判空方法
def is_empty(value):
    if value is None or str(value).strip() == '':
        return True
    return False


# 加密
import jwt


def encode_token(**kwargs):
    payload = kwargs
    key = "123"
    try:
        token = jwt.encode(payload=payload, key=key, algorithm='HS256')
        return token
    except Exception as e:
        print(f"编码过程中出现错误: {e}")
        return None


# 解密
def decode_token(token):
    key = "123"
    try:
        payload = jwt.decode(token, key, algorithms=['HS256'])
        return payload
    except Exception as e:
        print(f"解码过程中出现错误: {e}")
        return None
